﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static ClinicSystem.UserCon.genderChoose;

namespace ClinicSystem.UserCon
{

    public partial class genderChoose : UserControl
    {
        public event EventHandler<choosechangedEventArgs> ChoiceChanged;
        public class choosechangedEventArgs : EventArgs
        {
            public string value;
            public choosechangedEventArgs(string selectechoice)
            {
                value = selectechoice;
            }
        }
        public genderChoose()
        {
            InitializeComponent();
            radioButton1.CheckedChanged += RadioButton_CheckedChanged;
            radioButton2.CheckedChanged += RadioButton_CheckedChanged;
            radioButton3.CheckedChanged += RadioButton_CheckedChanged;
        }

        internal string choose = "";
        private void RadioButton_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rdbtn = sender as RadioButton;

            if (Convert.ToInt32(rdbtn.Tag) == 1)
            {
                radioButton1.Checked = true;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                choose = radioButton1.Text;
            }
            else if (Convert.ToInt32(rdbtn.Tag) == 2)
            {
                radioButton1.Checked = false;
                radioButton2.Checked = true;
                radioButton3.Checked = false;
                choose = radioButton2.Text;
            }
            else if (Convert.ToInt32(rdbtn.Tag) == 3)
            {
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = true;
                choose = radioButton3.Text;
            }
            ChoiceChanged?.Invoke(this, new choosechangedEventArgs(choose));

        }

        //private void GenderChoose_ChoiceChanged(object sender, choosechangedEventArgs e)
        //{
        //    string selectedChoice = e.value;
        //    // 在这里可以使用 selectedChoice 值进行相应的操作
        //    MessageBox.Show("Selected choice: " + selectedChoice);
        //}
    }
}
